#!/usr/bin/env bash
################################################################################
# YourSpace CLI Manager Utility
# http://yourspace-cli.googlecode.com/svn/trunk/manager/
#
# NAME
#      ysmgr -- manage yourspace versions
#
# SYNOPSIS
#      ysmgr [-v] [file ...]
#
# DESCRIPTION
#      Enter a bare-bones interactive TLE (Top-Level Environment) in which you
#      can find out which yourspace variant is active, change or test different
#      language variants, and manipulate the ~/.yourspace/ files.
#
#      Further description will be written as the code progresses. See further
#      comments below within the code.
#
# LICENSE
#      Open-Source under the MIT License. Content licensed under CC-BY.
#      http://creativecommons.org/licenses/by/3.0/
#
################################################################################
#
# Copyright (c) 2008 David Christian Liedle
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
################################################################################

# Notes:
# Switch to just plain POSIX?
# I think I'll get the best results with BASH.
#
# Until the TLE/run-once code is in place, here's a startup output:
#

flexible_screen_clear()

echo
echo "YSMGR Version 0.1.0a R2"
echo "Welcome to the YourSpace CLI Manager!"
echo "Usage: ysmgr [-v]"
echo
echo "NOT YET IMPLEMENTED"
echo "View the YourSpace CLI Project Page on Google Code:"
echo "http://code.google.com/p/yourspace-cli/"
echo
echo "exiting... goodbye!"
echo

#
# Ok, we'll need a series of functions, one for each command that can be given:
#

flexible_screen_clear(){
    clear
    #cowsay:
    #figlet:
    #cursive:
    # or do nothing.
}

check_if_installed(){
    # check whether arg is an installed app with which, probly
    # return a useable value (including error, where needed)
    
    # brainstorm:
    # The likely targets of such a check would be:
    # - grep (and any non-bash, system-located commands needed)
    # - growlnotify
    # - figlet, cowsay, cursive
    # - lynx, links, emacs w3m
    # 
}

growl(){
    growlnotify -m ${1}
}

get_user_input(){
    # accept valid commands, return instruction command
    # (as error, where appropriate)
}

cmd_one(){
    # command
}

cmd_two(){
    # command
}

menu_one(){
    clear
    echo "Menu 1: "
}

# if [ $# > 0 ] then

    #
    # Valid flags:
    #
    # None at this time... Hmm.. How would people use them? Oooh, obviously version
    # number, help/usage info, and a command to install. Perhaps one to verify an
    # install... An auto-update command...
    #
    # Here's a temporary list to start that off:
    #
    # -v, -V   - echo version number and exit
    # -i, -I   - install YourSpace to default location (~/bin/yourspace@ -> ~/.yourspace/ )
    # -u, -U   - auto-update YourSpace to most recent version
    # -h, -H   - help/usage
    # -
    #

# else

    #
    # Assuming no flags were input, we're entering interactive mode as a TLE:
    #

    # clear
    
    

# fi

#
# And, when it's all over, we exit:
#

exit

